import React from "react"
import { useEffect, useState } from "react"
import useMount from "../../hooks/useMount.ts"

const TryUseMount = () => {
  const [count, setCount] = useState(0)

  // useEffect 在组件初始化时执行
  useEffect(() => {
    console.log("useEffect")
  }, [])

  // useMount 在组件初始化时执行
  // TODO 效果一样，但 useMount 更加语义化
  useMount(() => {
    console.log("useMount")
  })

  const handleClick = () => {
    console.log("handleClick事件触发")
    setCount(count + 1)
  }

  return (
    <div>
      <button onClick={handleClick}>count</button>
    </div>
  )
}

export default TryUseMount
